import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { User } from './User';

@Entity('articles')
export class Article {
    @PrimaryGeneratedColumn()
    id!: number;

    @Column({ length: 100 })
    title!: string;

    @Column('text')
    content!: string;

    @Column('simple-array', { nullable: true })
    images!: string[];

    @Column({ default: 0 })
    likes!: number;

    @Column({ default: 0 })
    comments!: number;

    @Column({ default: 0 })
    views!: number;

    @Column({ default: true })
    isPublic!: boolean;

    @Column({ default: 0 })
    status!: number; // 0: 正常, 1: 待审核, 2: 已下架

    @ManyToOne(() => User)
    @JoinColumn({ name: 'author_id' })
    author!: User;

    @Column()
    author_id!: number;

    @CreateDateColumn()
    created_at!: Date;

    @UpdateDateColumn()
    updated_at!: Date;
} 